<template>
	<view class="page">
		<empty :emptyImg="emptyImg" :emptyTxt="emptyTxt" v-if="isEmpty"></empty>
		<view class="comment" v-if="!isEmpty" v-for="(res, index) in dataList" :key="res.id">
			<view class="right">
				<view class="top">
					<view class="name">{{ res.title }}</view>
				</view>
				<view class="content">{{ res.content }}</view>
			</view>
			<view style="text-align: right;font-size: 22rpx;color: #909399;">{{res.create_time}}</view>
		</view>
		<u-loadmore :status="status" v-if="!isEmpty" color="#909399" :margin-top="20"/>
		<login-model ref="loginModel"></login-model>
		<hoverMenu></hoverMenu>
	</view>
</template>

<script>
	import hoverMenu from "@/components/public/sa-hover-menu.vue";
	import loginModel from "@/components/public/loginModel.vue";
	import empty from "@/components/public/empty.vue";
	import {userMessage} from "@/common/api.js";
export default {
	components: {
		loginModel, 
		empty,
		hoverMenu
	},
	data() {
		return {
			dataList: [],
			status: 'loadmore',
			pageSize: 10,
			pageStart: 1,
			total:0,
			isEmpty:false,
			emptyImg:"https://yunxingzhan.oss-cn-hangzhou.aliyuncs.com/miniprogram/images/images/empty_goods.png",
			emptyTxt:"暂无消息",
		};
	},
	onLoad() {
	},
	onShow: function() {
		this.dataList=[];
		this.pageStart = 1;
		this.selectMsg();
	},
	onReachBottom: function() {
		if(this.total/(this.pageStart*this.pageSize)>1){
			this.pageStart++;
			this.selectMsg();
		}else{
			this.status = 'nomore';
		}
	},
	methods: {
		floatTouchClick(index){
			this.$uniApi.floatTouch(index);
		},
		selectMsg(){
			userMessage(this,{page:this.pageStart,limit:this.pageSize});
		}
	}
};
</script>
<style>
	page{
		font-family: PingFang SC;
		background: #f6f6f6;
	}
</style>
<style lang="scss" scoped>
.page{
	padding: 10px;
}
.comment {
	// display: flex;
	padding: 30rpx;
	background: #fff;
	margin-bottom: 10px;
	.left {
		image {
			width: 64rpx;
			height: 64rpx;
			border-radius: 50%;
			background-color: #f2f2f2;
		}
	}
	.right {
		flex: 1;
		padding-left: 20rpx;
		font-size: 30rpx;
		.top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10rpx;
			.name {
				color: #20cbd4;
			}
		}
		.content {
			margin-bottom: 10rpx;
			font-size: 25rpx;
		}
	}
}
</style>
